package com.mmall.util;

import com.mmall.common.ExceptionError;
import org.apache.commons.lang3.StringUtils;

/**
 * 层级生成工具
 */
public class LevelUtil {
    public static final String SEPARATOR = ".";

    public static final String ROOT = "0";

    private LevelUtil(){
        ExceptionError.throwError("你不能为LevelUtil进行实例化");
    }

    public static String calculateLevel(String parentLevel,int parentId){
        if (StringUtils.isBlank(parentLevel)){
            return ROOT;
        }else {
            return StringUtils.join(parentLevel,SEPARATOR,parentId);
        }
    }
}
